<template>
  <div class="game-card" @click="$emit('click', game);playBtnClick(game.engName)">
    <div class="game-image-container">
      <img :src="game.imageUrl" :alt="game.name" class="game-image">
<!--      <div class="game-tags">-->
<!--        <span v-for="tag in game.tags" :key="tag" class="game-tag">{{ tag }}</span>-->
<!--      </div>-->
    </div>

    <div class="game-info">
      <h3 class="game-name">{{ game.name }}</h3>


<!--      <div class="game-stats">-->
<!--        <div class="stat">-->
<!--          <i class="fas fa-users"></i>-->
<!--          <span>{{ game.playersOnline }} online</span>-->
<!--        </div>-->
<!--        <div class="stat">-->
<!--          <i class="fas fa-star"></i>-->
<!--          <span>{{ game.rating }}/5</span>-->
<!--        </div>-->
<!--      </div>-->
            <div class="game-stats">
              <div class="stat">
                <i class="fas fa-users"></i>
                <span v-if="game.minPlayer !== game.maxPlayer">游玩人数: {{game.minPlayer}}-{{game.maxPlayer}} 人</span>
                <span v-if="game.minPlayer === game.maxPlayer">游玩人数: {{game.maxPlayer}} 人</span>
              </div>
            </div>
    </div>

    <button class="play-button" @click="playBtnClick(game.id)">PLAY NOW</button>

    <div class="hover-effect"></div>
  </div>
</template>

<script setup>
import router from "@/routers/index.js";

defineProps({
  game: {
    type: Object,
    required: true
  }
})

const playBtnClick = (id) => {
  router.push({ name: 'GameRoom', params: { gameId: id } });

}
defineEmits(['click'])
</script>

<style scoped>
.game-card {
  position: relative;
  background: rgba(26, 26, 46, 0.8);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.game-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.game-card:hover .hover-effect {
  opacity: 1;
}

.game-image-container {
  position: relative;
  width: 100%;
  height: 150px;
  overflow: hidden;
}

.game-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.game-card:hover .game-image {
  transform: scale(1.05);
}

.game-tags {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  gap: 5px;
}

.game-tag {
  background: rgba(76, 201, 240, 0.8);
  color: white;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
}

.game-info {
  padding: 15px;
}

.game-name {
  margin: 0 0 5px;
  color: white;
  font-size: 1.2rem;
}

.game-description {
  margin: 0 0 15px;
  color: #a5a5a5;
  font-size: 0.9rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.game-stats {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #a5a5a5;
  font-size: 0.8rem;
}

.stat i {
  color: #4cc9f0;
}

.play-button {
  width: 100%;
  padding: 10px;
  background: linear-gradient(90deg, #4cc9f0 0%, #4361ee 100%);
  color: white;
  border: none;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.play-button:hover {
  background: linear-gradient(90deg, #4361ee 0%, #4cc9f0 100%);
}

.hover-effect {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(76, 201, 240, 0.1) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
</style>
